# ifndef __HoluxCrd_H_
# define __HoluxCrd_H_

# ifdef _MSC_VER
#	pragma pack (push, 1)
# endif

enum CrdLanguage {
	clAscii7     = 2,
	clSBCS       = 1,
	clMBCSTaiwan = 0,
	clMBCSKorean = 3
};

enum CrdCountry {
	cnTaiwan        =  1,
	cnFrance        =  2,
	cnAndorra       =  3,
	cnMonaco        =  4,
	cnSpain         =  5,
	cnAustria       =  6,
	cnBelgium       =  7,
	cnItaly         =  8,
	cnSwitzerland   =  9,
	cnLiechtenstein = 10,
	cnLuxembourg    = 11,
	cnNetherlangs   = 12,
	cnEngland       = 13,
	cnScotland      = 14,
	cnWales         = 15,
	cnGermany       = 16,
	cnVatican       = 17,
	cnSanmarino     = 18,
	cnPortugal      = 19,
	cnUnitedStates  = 20,
	cnCanada        = 21,
	cnDenmark       = 22,
	cnSweden        = 23,
	cnJapan         = 24,
	cnThailand      = 25,
	cnPhilippine    = 26,
	cnChina         = 27,
	cnKorea         = 28,
	cnMalaysia      = 29,
	cnIndonesia     = 30,
	cnIran          = 31,
	cnRussia        = 32,
	cnIraq          = 33,
	cnEgypt         = 34,
	cnSouthAfrica   = 35,
	cnAustralia     = 36,
	cnNewZeland     = 37,
	cnPoland        = 38,
	cnFinland       = 39,
	cnNorway        = 40,
	cnTurkey        = 41,
	cnGreece        = 42,
	cnBrazil        = 43,
	cnArgentina     = 44,
	cnMexico        = 45,
	cnSlovakia      = 46,
	// NOTE: missed in the specification, but presented in Europe.crd
	cnEurope        = 47,

	// These values are defined in ARD specification only.
	cnIreland       = 48,
	cnCzech         = 49,
	cnAsia          = 50,
	cnAfrica        = 51,
	cnAmerica       = 52,
	cnOceania       = 53,
};

const size_t c_cCrdTypes = 51;

struct CCrdHdr {
	BYTE  btAdmLevel;
	BYTE  btReserved [3];

	DWORD dwAdmDataOffset;
	DWORD dwSubadmDataOffset;

	WORD  wCountry;   // see CCrdCountry
	WORD  wAdmNum;
	WORD  wSubadmNum;

	WORD  wReserved0;

	DWORD dwIndexOffset;
	DWORD dwIndexSize;

	BYTE  btLanguage; // see CCrdLanguage
	BYTE  btBase;

	WORD  wReserved1;
	DWORD dwReserved2;
	DWORD dwReserved3;
	DWORD dwReserved4;
	DWORD dwReserved5;
	DWORD dwReserved6;
};

struct CCrdStringRef {
	DWORD dwLen    : 6,
	      dwOffset : 26;
};

struct CCrdAdm {
	CCrdStringRef Name;
	DWORD dwOrdinal;
	DWORD dwSubadmOffset;
	WORD  wNation;
	WORD  wSubadmNum;
};

struct CCrdSubadm {
	CCrdStringRef Name;
	DWORD dwOrdinal;
};

struct CCrdSearchItem {
	WORD  wAdmId;
	WORD  wNum;
	DWORD dwIndex;
};

struct CCrdIndexItem {
	DWORD dwNameLen : 6,
	      dwNameIdx : 26;

	DWORD dwAdmId;
	DWORD dwOffset;

	SHORT shBackward;
	SHORT shForward;
};

struct CCrdMapHdr {
	char  strName [32];
	DWORD dwMapId;
	DWORD dwVer;
	BYTE  btDatum;
	BYTE  btContent;

	BYTE  btTypeNum;
	BYTE  btScaleNum;

	DWORD dwScalesOffset;
	DWORD dwBlocksOffset;
	DWORD dwTypesOffset;

	DWORD dwPolylinesOffset;
	DWORD dwPolygonsOffset;
	DWORD dwPointsOffset;

	DWORD dwPolylinePartOffset;
	DWORD dwPolygonPartOffset;

	DWORD dwPtsOffset;

	DWORD dwOwnerOffset;
	DWORD dwReqOffset;
	DWORD dwShtOffset;
	DWORD dwOwner0Offset;
	DWORD dwOwner1Offset;
	DWORD dwOwner2Offset;
	DWORD dwOwner3Offset;

	LONG  lX0, lY1, lX1, lY0;
};

struct CCrdScale {
	LONG lX0;
	LONG lY0;
	DWORD dwBlockWidth;
	DWORD dwBlockHeight;
	DWORD dwRows;
	DWORD dwCols;

	DWORD dwFirstBlockIdx;
	DWORD dwBlocks;

	DWORD dwOwnerIdx;
	DWORD dwOwnerNum;
};

struct CCrdBlock {
	DWORD dwFirstTypeIdx;
	DWORD dwTypes;
};

struct CCrdType {
	DWORD dwFirstElemIdx;
	DWORD dwElems;
	DWORD dwElemType;
};

struct CCrdObject {
	CCrdStringRef Label;
	DWORD dwAdmId;
};

struct CCrdPolyBase : public CCrdObject {
	DWORD dwFirstPointIdx;
	DWORD dwPoints;

	LONG  lX0, lY1, lX1, lY0;

	WORD  wCenterX, wCenterY;
};

struct CCrdPolygon  : public CCrdPolyBase {};
struct CCrdPolyline : public CCrdPolyBase {};

struct CCrdPoint : public CCrdObject {
	LONG  lX, lY;
};

struct CCrdPt {
	WORD  wX, wY;
};

# ifdef _MSC_VER
#	pragma pack (pop)
# endif


# endif // __HoluxCrd_H_